/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jeggtimer;

import java.util.Timer;
import java.util.TimerTask;
import javax.swing.JOptionPane;
import org.jdesktop.application.ResourceMap;

/**
 *
 * @author User
 */
public class Ticker {
    int min;
    int sec;
    boolean going;
    Timer timer;
    JeggtimerView view;
    public Ticker(){
        timer = new Timer();
        min=000;
        sec=0;
        going=false;
    }
    public String minAsStr(){
        return Integer.toString(min);
    }
    public String secAsStr(){
        return Double.toString(sec);
    }
    public void decrementSec(ResourceMap resourceMap){
        if(sec<=00){
            if(min<=0){
                stop(view.getResourceMap());
            }
            min--;
            sec=60;
        }
          sec-=1;
    }
    public int getMin() {
        return min;
    }
    public void stop(ResourceMap resourceMap){
        view.getjButton1().setIcon(resourceMap.getIcon("startButton.icon"));
        timer.cancel();
        sec=0;
        min=0;
        going=false;
        new AePlayWave("C:\\WINDOWS\\Media\\ringin.wav").start();
        JOptionPane.showMessageDialog(null, "Time's Up!");
        view.getJTextField1().setText("Do");
        view.getJTextField2().setText("ne!");
    }
    public void setView(JeggtimerView jv){
        this.view=jv;
    }
    public void setMin(int min) {
        this.min = min;
    }

    public int getSec() {
        return sec;
    }

    public void setSec(int sec) {
        this.sec = sec;
    }
    public void decrementMin(){
        min--;
    }
    public boolean going(){
        return going;
    }

    void setGoing(boolean b) {
        going=b;
    }
    
  
}
